package com.nuesoft.ysu.elm99.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuesoft.ysu.elm99.entity.Dept;
import com.nuesoft.ysu.elm99.mapper.DeptMapper;
import com.nuesoft.ysu.elm99.service.IDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class IDeptServiceImpl implements IDeptService {
    @Autowired
    DeptMapper deptMapper;

    @Override
    public List<Dept> findAll() {

        return deptMapper.selectList(null);//11.无条件查找
    }
//在service层实现分页查询
    @Override
    public IPage<Dept> page4Index(int pageIndex, int pagecount, int wrap) {
        IPage<Dept> page = new Page<>(pageIndex,pagecount);
        QueryWrapper<Dept> wrapper=new QueryWrapper<>();
        wrapper.gt("deptid",wrap);
        wrapper.orderByAsc("dname");
        IPage<Dept> rest = deptMapper.selectPage(page,wrapper);

        return rest;
    }
}
